My Project
Namespaces | Data Structures | Typedefs | Enumerations | Functions
vspace Namespace Reference

Namespaces

namespace  internals
 

Data Structures

class  DequeueEvent
 
struct  DictSpec
 
class  EnqueueEvent
 
class  Event
 
class  EventSet
 
class  Queue
 
struct  Result
 
class  Semaphore
 
struct  Status
 
class  SyncReadEvent
 
class  SyncVar
 
class  VMap
 
struct  VRef
 
struct  VRef< void >
 
class  VString
 
class  WaitSemaphoreEvent
 
struct  ZRef
 

Typedefs

typedef VMap< DictSpecVDict
 
typedef internals::Mutex FastLock
 
typedef internals::Mutex Mutex
 

Enumerations

enum  ErrCode {
  ErrNone , ErrGeneral , ErrFile , ErrMMap ,
  ErrOS
}
 

Functions

pid_t fork_process ()
 
static Status vmem_init ()
 
static void vmem_deinit ()
 
template<typename T >
VRef< Tvnull ()
 
template<typename T >
VRef< Tvnew ()
 
template<typename T >
VRef< Tvnew_uninitialized ()
 
template<typename T >
VRef< Tvnew_array (size_t n)
 
template<typename T >
VRef< Tvnew_uninitialized_array (size_t n)
 
template<typename T , typename Arg >
VRef< Tvnew (Arg arg)
 
template<typename T , typename Arg1 , typename Arg2 >
VRef< Tvnew (Arg1 arg1, Arg2 arg2)
 
template<typename T , typename Arg1 , typename Arg2 , typename Arg3 >
VRef< Tvnew (Arg1 arg1, Arg2 arg2, Arg3 arg3)
 
template<typename T , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 >
VRef< Tvnew (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
 
template<typename T , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 >
VRef< Tvnew (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5)
 
template<typename T >
ZRef< Tznull ()
 
template<typename T >
ZRef< Tznew ()
 
template<typename T >
ZRef< Tznew_uninitialized ()
 
template<typename T >
ZRef< Tznew_array (size_t n)
 
template<typename T >
ZRef< Tznew_uninitialized_array (size_t n)
 
template<typename T , typename Arg >
ZRef< Tznew (Arg arg)
 
template<typename T , typename Arg1 , typename Arg2 >
ZRef< Tznew (Arg1 arg1, Arg2 arg2)
 
template<typename T , typename Arg1 , typename Arg2 , typename Arg3 >
ZRef< Tznew (Arg1 arg1, Arg2 arg2, Arg3 arg3)
 
static VRef< VStringvstring (const char *s)
 
static VRef< VStringvstring (const char *s, size_t len)
 
static VRef< VStringvstring (size_t len)
 

Typedef Documentation

◆ FastLock

Definition at line 1005 of file vspace.h.

◆ Mutex

Definition at line 1008 of file vspace.h.

◆ VDict

Definition at line 998 of file vspace.h.

Enumeration Type Documentation

◆ ErrCode

Enumerator
ErrNone 
ErrGeneral 
ErrFile 
ErrMMap 
ErrOS 

Definition at line 42 of file vspace.h.

42 {
43 ErrNone,
45 ErrFile,
46 ErrMMap,
47 ErrOS,
48};
@ ErrGeneral
Definition: vspace.h:44
@ ErrOS
Definition: vspace.h:47
@ ErrNone
Definition: vspace.h:43
@ ErrFile
Definition: vspace.h:45
@ ErrMMap
Definition: vspace.h:46

Function Documentation

◆ fork_process()

pid_t vspace::fork_process ( )

Definition at line 419 of file vspace.cc.

419 {
420 using namespace internals;
422 for (int p = 0; p < MAX_PROCESS; p++) {
423 if (vmem.metapage->process_info[p].pid == 0) {
424 pid_t pid = fork();
425 if (pid < 0) {
426 // error
427 return -1;
428 } else if (pid == 0) {
429 // child process
430 int parent = vmem.current_process;
433 vmem.metapage->process_info[p].pid = getpid();
435 send_signal(parent);
436 } else {
437 // parent process
439 wait_signal();
440 // child has unlocked metapage, so we don't need to.
441 }
442 return pid;
443 }
444 }
446 return -1;
447}
int p
Definition: cfModGcd.cc:4080
void unlock_metapage()
Definition: vspace.cc:310
ipc_signal_t wait_signal(bool lock)
Definition: vspace.cc:413
void lock_metapage()
Definition: vspace.cc:306
static const int MAX_PROCESS
Definition: vspace.h:86
static VMem & vmem
Definition: vspace.h:300
ProcessInfo process_info[MAX_PROCESS]
Definition: vspace.h:180
bool send_signal(int processno, ipc_signal_t sig, bool lock)
Definition: vspace.cc:347
MetaPage * metapage
Definition: vspace.h:253

◆ vmem_deinit()

static void vspace::vmem_deinit ( )
inlinestatic

Definition at line 407 of file vspace.h.

407 {
409}

◆ vmem_init()

static Status vspace::vmem_init ( )
inlinestatic

Definition at line 403 of file vspace.h.

403 {
404 return internals::vmem.init();
405}
Status init(int fd)
Definition: vspace.cc:29

◆ vnew() [1/6]

template<typename T >
VRef< T > vspace::vnew ( )

Definition at line 537 of file vspace.h.

537 {
539 new (result.to_ptr()) T();
540 return result;
541}
return result
Definition: facAbsBiFact.cc:75
STATIC_VAR jList * T
Definition: janet.cc:30

◆ vnew() [2/6]

template<typename T , typename Arg >
VRef< T > vspace::vnew ( Arg  arg)

Definition at line 566 of file vspace.h.

566 {
568 new (result.to_ptr()) T(arg);
569 return result;
570}

◆ vnew() [3/6]

template<typename T , typename Arg1 , typename Arg2 >
VRef< T > vspace::vnew ( Arg1  arg1,
Arg2  arg2 
)

Definition at line 573 of file vspace.h.

573 {
575 new (result.to_ptr()) T(arg1, arg2);
576 return result;
577}

◆ vnew() [4/6]

template<typename T , typename Arg1 , typename Arg2 , typename Arg3 >
VRef< T > vspace::vnew ( Arg1  arg1,
Arg2  arg2,
Arg3  arg3 
)

Definition at line 580 of file vspace.h.

580 {
582 new (result.to_ptr()) T(arg1, arg2, arg3);
583 return result;
584}

◆ vnew() [5/6]

template<typename T , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 >
VRef< T > vspace::vnew ( Arg1  arg1,
Arg2  arg2,
Arg3  arg3,
Arg4  arg4 
)

Definition at line 588 of file vspace.h.

588 {
590 new (result.to_ptr()) T(arg1, arg2, arg3, arg4);
591 return result;
592}

◆ vnew() [6/6]

template<typename T , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 >
VRef< T > vspace::vnew ( Arg1  arg1,
Arg2  arg2,
Arg3  arg3,
Arg4  arg4,
Arg5  arg5 
)

Definition at line 596 of file vspace.h.

596 {
598 new (result.to_ptr()) T(arg1, arg2, arg3, arg4, arg5);
599 return result;
600}

◆ vnew_array()

template<typename T >
VRef< T > vspace::vnew_array ( size_t  n)

Definition at line 550 of file vspace.h.

550 {
552 T *ptr = result.as_ptr();
553 for (size_t i = 0; i < n; i++) {
554 new (ptr + i) T();
555 }
556 return result;
557}
int i
Definition: cfEzgcd.cc:132

◆ vnew_uninitialized()

template<typename T >
VRef< T > vspace::vnew_uninitialized ( )

Definition at line 544 of file vspace.h.

544 {
546 return result;
547}

◆ vnew_uninitialized_array()

template<typename T >
VRef< T > vspace::vnew_uninitialized_array ( size_t  n)

Definition at line 560 of file vspace.h.

560 {
562 return result;
563}

◆ vnull()

template<typename T >
VRef< T > vspace::vnull ( )

Definition at line 532 of file vspace.h.

532 {
534}
const vaddr_t VADDR_NULL
Definition: vspace.h:84

◆ vstring() [1/3]

static VRef< VString > vspace::vstring ( const char *  s)
inlinestatic

Definition at line 766 of file vspace.h.

766 {
767 return vnew<VString>(s);
768}
const CanonicalForm int s
Definition: facAbsFact.cc:51

◆ vstring() [2/3]

static VRef< VString > vspace::vstring ( const char *  s,
size_t  len 
)
inlinestatic

Definition at line 770 of file vspace.h.

770 {
771 return vnew<VString>(s, len);
772}

◆ vstring() [3/3]

static VRef< VString > vspace::vstring ( size_t  len)
inlinestatic

Definition at line 774 of file vspace.h.

774 {
775 return vnew<VString>(len);
776}

◆ znew() [1/4]

template<typename T >
ZRef< T > vspace::znew ( )

Definition at line 680 of file vspace.h.

680 {
682 new (result.to_ptr()) T();
683 return result;
684}

◆ znew() [2/4]

template<typename T , typename Arg >
ZRef< T > vspace::znew ( Arg  arg)

Definition at line 709 of file vspace.h.

709 {
711 new (result.to_ptr()) T(arg);
712 return result;
713}

◆ znew() [3/4]

template<typename T , typename Arg1 , typename Arg2 >
ZRef< T > vspace::znew ( Arg1  arg1,
Arg2  arg2 
)

Definition at line 716 of file vspace.h.

716 {
718 new (result.to_ptr()) T(arg1, arg2);
719 return result;
720}

◆ znew() [4/4]

template<typename T , typename Arg1 , typename Arg2 , typename Arg3 >
ZRef< T > vspace::znew ( Arg1  arg1,
Arg2  arg2,
Arg3  arg3 
)

Definition at line 723 of file vspace.h.

723 {
725 new (result.to_ptr()) T(arg1, arg2, arg3);
726 return result;
727}

◆ znew_array()

template<typename T >
ZRef< T > vspace::znew_array ( size_t  n)

Definition at line 693 of file vspace.h.

693 {
695 T *ptr = result.as_ptr();
696 for (size_t i = 0; i < n; i++) {
697 new (ptr + i) T();
698 }
699 return result;
700}

◆ znew_uninitialized()

template<typename T >
ZRef< T > vspace::znew_uninitialized ( )

Definition at line 687 of file vspace.h.

687 {
689 return result;
690}

◆ znew_uninitialized_array()

template<typename T >
ZRef< T > vspace::znew_uninitialized_array ( size_t  n)

Definition at line 703 of file vspace.h.

703 {
705 return result;
706}

◆ znull()

template<typename T >
ZRef< T > vspace::znull ( )

Definition at line 675 of file vspace.h.

675 {
677}